package com.ydlclass;

import com.ydlclass.channelHandler.ConsumerChannelInitializer;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import lombok.extern.slf4j.Slf4j;

/**
 * 提供bootstrap单例
 *
 * @author Knife
 */
@Slf4j
public class NettyBootStrapInitializer {

    private static Bootstrap bootstrap = new Bootstrap();

    static {
        // todo ： 有一个问题，以后进行扩展怎么办？

        NioEventLoopGroup group = new NioEventLoopGroup();

        bootstrap.group(group)
                .channel(NioSocketChannel.class)
                .handler(new ConsumerChannelInitializer());
    }

    private NettyBootStrapInitializer(){
    }

    public static Bootstrap getBootstrap() {
        return bootstrap;
    }
}
